<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body></body>

</html>
<script>
    function a(str) {
        // 字符串反转
        str.split(" ");
        console.log(str.split(" "));
        let arr = str.split(" ");
        arr.reverse();
        console.log(arr);
        console.log(arr[1].toUpperCase());
        console.log(arr[1].split("")[0].toUpperCase());
        let newArr = arr[1].split("");
        // World
        var sum = "";
        for (let i = 1; i < newArr.length; i++) {
            sum += newArr[i];
        }
        console.log(arr[1].split("")[0].toUpperCase() + sum);
        arr[1] = arr[1].split("")[0].toUpperCase() + sum;
        // Hello
        let newArr2 = arr[2].split("");
        var sum2 = "";
        for (let i = 1; i < newArr2.length; i++) {
            sum2 += newArr2[i];
        }
        console.log(arr[2].split("")[0].toUpperCase() + sum2);
        arr[2] = arr[2].split("")[0].toUpperCase() + sum2;
        arr.join("");
        console.log(arr);
        var newarr2 = arr.map((item, index) => {
            return item.split("").reverse();
        });
        console.log(newarr2);
        let newArr3 = [];
        newarr2.forEach((item, index) => {
            newArr3.push(item.join("").trim());
        });
        newArr3.forEach((item, index, arrs) => {
            arrs[0] = "你爱我";
        });
        
        console.log(newArr3.join(''));
    }
    a("hello world 我爱你！");
</script>